bitkeeper revision 1.1642 (429f43a9Urbk2TjIlm7NZJ_Z8LDQQQ)
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 2 Jun 2005 17:36:41 +0000 (17:36 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 2 Jun 2005 17:36:41 +0000 (17:36 +0000)
l?e_from_paddr() expects the physical address to already be page
aligned. Fix map_domain_mem() to do this, and add an assertion to the
macros to check for it in debug builds.
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/x86_32/domain_page.c
xen/include/asm-x86/page.h

index 4ede10b0553eb1e4b0a89337f39b6ab1199fc5e4..08673b2986919384818bfb2f7ca843b2b55bd14d 100644 (file)
@@ -72,7 +72,7 @@ void *map_domain_mem(unsigned long pa)
     }
     while ( l1e_get_flags(cache[idx]) & _PAGE_PRESENT );
 
-    cache[idx] = l1e_from_paddr(pa, __PAGE_HYPERVISOR);
+    cache[idx] = l1e_from_paddr(pa & PAGE_MASK, __PAGE_HYPERVISOR);
 
     spin_unlock(&map_lock);
 
index 258ec2df850aaef9b0105fa3f643dc175b9a57b1..126f3591ab39933388800c0890525e4daa69b318 100644 (file)
     ((l4_pgentry_t) { ((intpte_t)(pfn) << PAGE_SHIFT) | put_pte_flags(flags) })
 
 /* Construct a pte from a physical address and access flags. */
-#define l1e_from_paddr(pa, flags)  \
-    ((l1_pgentry_t) { (pa) | put_pte_flags(flags) })
-#define l2e_from_paddr(pa, flags)  \
-    ((l2_pgentry_t) { (pa) | put_pte_flags(flags) })
-#define l3e_from_paddr(pa, flags)  \
-    ((l3_pgentry_t) { (pa) | put_pte_flags(flags) })
-#define l4e_from_paddr(pa, flags)  \
-    ((l4_pgentry_t) { (pa) | put_pte_flags(flags) })
+#ifndef __ASSEMBLY__
+static inline l1_pgentry_t l1e_from_paddr(physaddr_t pa, unsigned int flags)
+{
+    ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0);
+    return (l1_pgentry_t) { pa | put_pte_flags(flags) };
+}
+static inline l2_pgentry_t l2e_from_paddr(physaddr_t pa, unsigned int flags)
+{
+    ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0);
+    return (l2_pgentry_t) { pa | put_pte_flags(flags) };
+}
+#if CONFIG_PAGING_LEVELS >= 3
+static inline l3_pgentry_t l3e_from_paddr(physaddr_t pa, unsigned int flags)
+{
+    ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0);
+    return (l3_pgentry_t) { pa | put_pte_flags(flags) };
+}
+#endif
+#if CONFIG_PAGING_LEVELS >= 4
+static inline l4_pgentry_t l4e_from_paddr(physaddr_t pa, unsigned int flags)
+{
+    ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0);
+    return (l4_pgentry_t) { pa | put_pte_flags(flags) };
+}
+#endif
+#endif /* !__ASSEMBLY__ */
 
 /* Construct a pte from its direct integer representation. */
 #define l1e_from_intpte(intpte)    ((l1_pgentry_t) { (intpte_t)(intpte) })